/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.joint.date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author atila
 */
public final class DateFormat {

   /**
    * The default date format.
    */
   public static final String TIMESTAMP_FORMAT_DEF = "dd/MM/yyyy HH:mm:ss";

   /**
    * The alternative date format.
    */
   public static final String TIMESTAMP_FORMAT_ALT = "dd-MM-yyyy HH:mm:ss";

   /**
    * The default String date format
    */
   public static final String DATE_FORMAT_DEF = "dd/MM/yyyy";

   /**
    * The alternative String date format
    */
   public static final String DATE_FORMAT_ALT = "dd-MM-yyyy";

   private DateFormat(){}

   public static String fromDateToString(Date date) {
      return new SimpleDateFormat(TIMESTAMP_FORMAT_DEF).format(date);
   }

   public static String fromDateToString(Date date, String format) {
      return new SimpleDateFormat(format).format(date);
   }

   public static Date fromStringToDate(String date) throws ParseException {
      return new SimpleDateFormat(DATE_FORMAT_DEF).parse(date);
   }

   public static Date fromStringToDate(String date, String format) throws ParseException {
      return new SimpleDateFormat(format).parse(date);
   }
}
